package com.jackstraw.jack_base.rules.exception;

import com.jackstraw.jack_base.rules.entity.enums.ResultEnum;
import com.jackstraw.jack_base.util.entity.response.ResultInterface;
import com.jackstraw.jack_base.util.exception.BadException;
import com.jackstraw.jack_base.util.exception.enums.ExceptionEnum;

/**
 * 规则异常
 */
public class BadRuleException extends BadException {
    public BadRuleException() {
        super();
    }

    public BadRuleException(String errorKey, Object... obj) {
        super(errorKey, obj);
    }

    public BadRuleException(ResultInterface resultInterface) {
        super(resultInterface);
    }

    public BadRuleException(ResultInterface resultInterface, Throwable cause) {
        super(resultInterface, cause);
    }

    public BadRuleException(String errorKey) {
        super(errorKey);
    }

    public BadRuleException(String errorCode, String errorMsg) {
        super(errorCode(errorCode), errorMsg);
    }

    public BadRuleException(String errorCode, String errorMsg, Object... obj) {
        super(errorCode(errorCode), errorMsg, obj);
    }

    public BadRuleException(String errorCode, String errorMsg, Throwable cause) {
        super(errorCode(errorCode), errorMsg, cause);
    }

    public BadRuleException(String errorCode, String errorMsg, Throwable cause, Object... obj) {
        super(errorCode(errorCode), errorMsg, cause, obj);
    }

    public BadRuleException(ResultEnum resultEnum) {
        super(errorCode(resultEnum.getCode()), resultEnum.getMessage());
    }

    public BadRuleException(ResultEnum resultEnum, Throwable cause) {
        super(errorCode(resultEnum.getCode()), resultEnum.getMessage(), cause);
    }


    public static String errorCode(String errorCode) {
        return BadException.bulidErrorCode(ExceptionEnum.RULES, errorCode);
    }

}
